import graphene
from flask import Flask
from flask_graphql import GraphQLView


class Query(graphene.ObjectType):
    me = graphene.String(
        name='my_info',
        sex=graphene.String(default_value='女'),
        desc=graphene.String(required = True),
        )

    def resolve_me(self,info,sex,desc):
        print(self)
        print('=================')
        print(info)
        return f"Hello! sex:{sex} desc :{desc}"

'''
name    # 重名名
required
default_value
传递参数:
    graphene.String(<参数名：参数类型>)
    resolve_me(root,info,<参数名>)
'''

if __name__ =='__main__':
    schema = graphene.Schema(query= Query)
    app = Flask(__name__)
    app.add_url_rule('/graphql',view_func=GraphQLView.as_view('grapql',schema=schema, graphiql=True))
    app.run(debug=True)